package grammarLearn

import "fmt"

type NestedPtred struct {
}

func (n *NestedPtred) GetName() string {
	return "NestedPtred"
}

type NestedPtrTest struct {
	Name string
	*NestedPtred
}

func (n *NestedPtrTest) GetName() string {
	return "NestedPtrTest"
}

func RunNestedPtr() {
	var ptr1, ptr2 *NestedPtred
	ptr1 = &NestedPtred{}
	fmt.Println("ori struct test:", ptr1.GetName()) //ori struct test: NestedPtred
	//ptr2 = &NestedPtrTest{}//cannot use &NestedPtrTest{} (value of type *NestedPtrTest) as *NestedPtred value in assignment (exit status 1)
	obj := &NestedPtrTest{}
	ptr2 = obj.NestedPtred
	fmt.Println("dev struct test:", ptr2.GetName()) //dev struct test: NestedPtred //没能多态
}
